﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CityGateway.Objects;

namespace CityServer
{
    public partial class CityView : UserControl
    {

        private Dictionary<int, int> m_evacs = new Dictionary<int, int>();
        private Dictionary<int, int> m_immigrants = new Dictionary<int, int>();



        public CityView()
        {
            InitializeComponent();

             
           // CitizenTree.NodeMouseClick += new TreeNodeMouseClickEventHandler(CitizenTree_NodeMouseClick);
        }

      

        private City m_City;

        public City City
        {
            set
            {
                m_City = value;
            }
            get 
            {
                return m_City;
            }
        }



        public void UpdateImmigrants(Dictionary<int, int> immigrants)
        {
            m_immigrants = immigrants;
            //this.Evacs.SelectedObject = evacs;
        }

        public void UpdateEvacs(Dictionary<int, int> evacs)
        {
            m_evacs = evacs;
            //this.Evacs.SelectedObject = evacs;
        }

        public void Bind()
        {
            Properties.SelectedObject = m_City.CityStatus;
            Evacs.SelectedObject = m_evacs.ToArray();
            Immigrants.SelectedObject = m_immigrants.ToArray();
        /*    Properties.i
            UserID.Text = m_City.UserID.ToString();
            CityName.Text = m_City.CityName;
            Population.Text = m_City.CityStatus.Population.Total.ToString();
            TotalJobs.Text = m_City.CityStatus.JobsTotal.ToString();
            TotalFlats.Text = m_City.CityStatus.ResidentialAvailable.ToString();
            CityDate.Text = m_City.CityStatus.CityDate.ToString();

        */
 

           


            

          //  CitizenTree.Nodes.Clear();

            //List<Citizen> FirstLevelCitizens = (from c in m_City.Population
            //                                    where c.Level <1
            //                                    select c).ToList();

            //foreach (Citizen citizen in FirstLevelCitizens)
            //{
            //    TreeNode node = new TreeNode();
            //    node.Text = "Citizen X (" + citizen.Age.ToString() + ")";
            //    node.Tag = citizen;
            //    CitizenTree.Nodes.Add(node);
            //    if(citizen.Children!= null)
            //            AddCitizenNode(node, citizen);
            //}

        }


        //private void AddCitizenNode(TreeNode parentNode, Citizen citizen)
        //{


        //    foreach (Citizen child in citizen.Children)
        //    {
        //        TreeNode node = new TreeNode();
        //        node.Text = "Citizen X (" + child.Age.ToString() + ")";
        //        node.Tag = child;
        //        parentNode.Nodes.Add(node);
        //        if (child.Children != null)
        //                 AddCitizenNode(node,child);
        //    }


        //}


            protected override void  OnPaint(PaintEventArgs e)
            {
            base.OnPaint(e);


            Bind();


            }

            private void splitContainer2_Panel2_Paint(object sender, PaintEventArgs e)
            {

            }

            private void panel1_Paint(object sender, PaintEventArgs e)
            {

            }


        
    }
}
